Conversation
Remove unnecessary distinction between StatusCodeExcluder and StatusCodeSelector.
thomas-zahner
commented
Jan 14, 2026
This change also improves error handling with invalid status code values in the lychee cache file. Below is an example with an unrepresentable status code value of 20. Previously it was converted to "Error (cached)": [http://example.com/]: [20] https://example.com/foobar | Error (cached) Now it is detected as follows: [WARN] Error while loading cache: CSV deserialize error: record 18 (line: 19, byte: 961): invalid status code value, expected the value to be >= 100 and <= 999. Continuing without.
44d09c5 to
8901e58
Compare
Previously an invalid range for --cache-exclude-status contained "failed to parse accept range" which is rather confusing.
thomas-zahner
commented
Jan 14, 2026
| }; | ||
| if captures.get(2).is_none() { | ||
| return Self::new_from(start, u16::MAX); | ||
| return Self::new(start, MAX); |
Member
Author
There was a problem hiding this comment.
This is the bugfix with the 123.. example, it now ends at 999
Member
Author
|
@HadrienG2 & @katrinafyi feel free to take a look and review |
katrinafyi
approved these changes
Jan 14, 2026
Member
katrinafyi
left a comment
There was a problem hiding this comment.
looks very reasonable. always happy to see deduplication. miniscule comments :)
Reuse constant & document regex
mre
reviewed
Jan 14, 2026
Comment on lines
+67
to
+84
| Ok(code) => { | ||
| let code = StatusCode::from_u16(code).map_err(|_| { | ||
| use serde::de::Error; | ||
| D::Error::custom( | ||
| "invalid status code value, expected the value to be >= 100 and <= 999", | ||
| ) | ||
| })?; | ||
| if code.is_success() { | ||
| // classify successful status codes as cache status success | ||
| // Does not account for status code overrides passed through | ||
| // the 'accept' flag. Instead, this is handled at a higher level | ||
| // when the cache status is converted to a status. | ||
| Ok(CacheStatus::Ok(code)) | ||
| } else { | ||
| // classify redirects, client errors, & server errors as cache status error | ||
| Ok(CacheStatus::Error(Some(code))) | ||
| } | ||
| } |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1769. Previously
lychee example.com --accept 123..lead toError: invalid status code.In the process I've eliminated some primitive obsession with
u16where we actually meantStatusCode. This also improved error handling with invalid values in the lychee cache file. See commit messages for more information.Improves the error messages overall. For example prviously:
error: invalid value '123..1234' for '--cache-exclude-status <CACHE_EXCLUDE_STATUS>': failed to parse accept range: no range pattern foundNow:
error: invalid value '123..1234' for '--cache-exclude-status <CACHE_EXCLUDE_STATUS>': failed to parse range: values must represent valid status codes between 100 and 999 (inclusive)